<?php
namespace Service;

class SystemTask extends Base
{

    public function getDatabase()
    {
        return $this->get(DATABASE_SYSTEMTASK);
    }

    public function addTask($flag, $url, $sign, $total, $startTime, $endTime, $spanTime, $data)
    {
        $dateTime = getDateTime();
        $insert = [
            'dry_flag' => $flag,
            'dry_url' => $url,
            'dry_sign' => $sign,
            'dry_total' => $total,
            'dry_try' => 0,
            'dry_start_time' => $startTime,
            'dry_end_time' => $endTime,
            'dry_span_time' => $spanTime,
            'dry_next_time' => $startTime,
            'dry_status' => 1,
            'dry_finish' => 0,
            'dry_data' => $data,
            'dry_update_time' => $dateTime['date_time'],
            'dry_add_time' => $dateTime['date_time']
        ];
        return $this->getDatabase()->insert($insert);
    }

    public function getTaskList($pageSize = 1000)
    {
        return $this->getDatabase()->getTaskList($pageSize);
    }

}